package com.行为型模型.S中介者模式;


/**
 * //中介机构
 */
public class MediatorStructure extends Mediator {
    //首先中介结构必须知道所有 房主和租客的信息
    private HouseOwner houseOwner;
    private Tenant tenant;

    public HouseOwner getHouseOwner() {
        return houseOwner;
    }

    public void setHouseOwner(HouseOwner houseOwner) {
        this.houseOwner = houseOwner;
    }

    public Tenant getTenant() {
        return tenant;
    }

    public void setTenant(Tenant tenant) {
        this.tenant = tenant;
    }

    @Override
    public void contact(String msg, Person person) {
        if (person==houseOwner){
            //如果是房主，则租户获得消息
            tenant.getMsg(msg);
        }else{
            //反之则是房主获取消息
            houseOwner.getMsg(msg);
        }
    }
}
